package com.lanswon.qzsmk.controller.systemManageController;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lanswon.qzsmk.base.DwzPage;
import com.lanswon.qzsmk.base.HttpContants;
import com.lanswon.qzsmk.controller.cardManageController.BaseController;
import com.lanswon.qzsmk.model.SamCard;
import com.lanswon.qzsmk.service.systemManageService.ParamManageService;
import com.lanswon.qzsmk.vo.ResultVo;
import com.lanswon.qzsmk.vo.SamCardVo;

@Controller
@RequestMapping(value="/psamCardManage")
public class PsamCardManageController  {
	
	@Autowired
	ParamManageService pms;
	
	@RequiresPermissions("psamCardManage:index")
	@RequestMapping(value="/psamCardManageIndex",name="psam卡管理,psamCardManage:index",method=RequestMethod.GET)
	public String psamCardManageIndex(){
		return "PsamCardManage";
	}
	
	@RequiresPermissions("psamCardManage:getIssuePsamCard")
	@SuppressWarnings("unchecked")
	@RequestMapping(value="/getIssuePsamCard",name="获取PSAM发卡信息,psamCardManage:getIssuePsamCard",method=RequestMethod.POST)
	public @ResponseBody DwzPage<SamCard> getIssuePsamCard(SamCardVo sv,Integer pageNum,Integer numPerPage){
//		if(sv.getNumPerPage()==null){//加载页面时执行
//			sv.setCurrentPage(1);
//			sv.setNumPerPage(20);
//		}else {
//			if(sv.getCurrentPage()<=1||pageCount==0){
//				sv.setCurrentPage(1);
//			}else if(sv.getCurrentPage()>=pageCount&&pageCount!=0){
//				sv.setCurrentPage(pageCount);
//			}
//		}
		if(pageNum==null&&numPerPage==null){
			pageNum=1;
			numPerPage=20;			
		}
		sv.setCurrentPage(pageNum);
		sv.setNumPerPage(numPerPage);
		sv.setStartLine((sv.getCurrentPage()-1)*sv.getNumPerPage());
		ResultVo result=pms.querySamCardbyPage(sv);
		DwzPage<SamCard> dPage=null;
		if(result.getResultStatus().getCode()==HttpContants.RETURN_SUCCESS){
			dPage=(DwzPage<SamCard>) result.getServiceObject();
		}
		return dPage;
	}
}
